import * as types from "../types/quickOrderTypes";

const initialState = {
  loading: false,
  error: undefined,
  realName: "",
  mobile: "",
  area: "",
};

export default function quickOrderReducer(state = initialState, action) {
  switch (action.type) {
    case types.QUICKORDER_LOADING:
      return {
        ...state,
        loading: true,
      };
    case types.QUICKORDER_DONE:
      return {
        ...state,
        loading: false,
      };
    case types.QUICKORDER_ERROR:
      return {
        ...state,
        loading: false,
        error: action.error,
      };
    case types.QUICKORDER_CHANGE_CONTRACTOR:
      return {
        ...state,
        realName: action.realName,
      };
    case types.QUICKORDER_CHANGE_MOBILE:
      return {
        ...state,
        mobile: action.mobile,
      };
    case types.QUICKORDER_CHANGE_ADDRESS:
      return {
        ...state,
        area: action.area,
      };
    case types.QUICKORDER_UNMOUNT:
      return {
        ...initialState,
      };
    default:
      return state;
  }
}
